<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" >
        let number=18
        let person={
            name:"张三",
            gender:"男"
        }

        Object.defineProperty(person,'age',
         {
            get(){
                return number
            },
            set(value){//有set时不能使用writable属性
              console.log("有人修改了age属性")
              number=value
            },
          
           /* 
            get:function(){
                return number
            }
             */
         }
        )
        /* Object.defineProperty(
            person,'age',{
                value:20,
                enumerable:true, //控制属性是否可以被枚举，默认false
                writable:true, //控制属性是否可以被修改，默认false
                configurable:true //控制属性是否可以被删除
            }
        ) */
        console.log(person)
    </script>
</head>
<body>
    
</body>
</html>